package com.xpqh.ksg.modular.overseas.controller;

import com.xpqh.ksg.base.BaseController;
import com.xpqh.ksg.base.BaseResponseDTO;
import com.xpqh.ksg.modular.caseInfo.dto.KsgCaseListReqDTO;
import com.xpqh.ksg.modular.core.dto.KsgNewsListRespDTO;
import com.xpqh.ksg.modular.overseas.dto.KsgNewsListResp2DTO;
import com.xpqh.ksg.modular.overseas.service.IKsgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

@RestController
@RequestMapping(value = "ksg/searchByPc")
public class KsgSearchByPcController extends BaseController {
    @Autowired
    private IKsgService ksgService;

    @RequestMapping(method = RequestMethod.POST)
    public BaseResponseDTO process(@Valid @RequestBody KsgCaseListReqDTO req ) {

        KsgNewsListResp2DTO resp2DTO = new KsgNewsListResp2DTO();
        List<KsgNewsListRespDTO> newsList = ksgService.searchByPc(req.getPageNo(), req.getPageSize(),req.getSearch());
        resp2DTO.setNewsList(newsList);
        resp2DTO.setCount(ksgService.searchByPcCount(req.getSearch()));
        return renderResultOk(resp2DTO);
    }
}
